package jxc.servlet.info.goods;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jxc.data.hibernate.dao.GoodsDAO;
import jxc.data.hibernate.pojo.Goods;

/**
 * Servlet implementation class Detail
 */
@WebServlet("/info/goods/detail")
public class Detail extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Detail() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id=request.getParameter("id");
		GoodsDAO dao=new GoodsDAO();
		Goods good=dao.getById(id);
		if(good==null){
			response.setCharacterEncoding("UTF-8");
			response.getWriter().print("找不到此商品");
			return;
		}
		request.setAttribute("good", good);
		request.getRequestDispatcher("/info/goods/detail.jsp").forward(request, response);
	}


}
